using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace stringconversions.tests
{
    [TestFixture]
    public class test_CreateDictionary
    {
        [Test]
        public void from_several_settings()
        {
            var dict = StringConversions.CreateDictionary(new[]
                                                   {
                                                       new Tuple<Parameter, Value>(new Parameter{Name="a"}, new Value{Data="1"}),
                                                       new Tuple<Parameter, Value>(new Parameter{Name="b"}, new Value{Data="2"})
                                                   });
            Assert.AreEqual(new Dictionary<string, string>{{"a", "1"}, {"b", "2"}}, dict);
        }


        [Test]
        public void with_no_elements_from_empty_list()
        {
            var dict = StringConversions.CreateDictionary(new Tuple<Parameter, Value>[0]);
            Assert.AreEqual(0, dict.Count);
        }


        [Test, ExpectedException(typeof(ArgumentException))]
        public void with_multiple_settings_for_same_param()
        {
            var dict = StringConversions.CreateDictionary(new[]
                                                   {
                                                       new Tuple<Parameter, Value>(new Parameter{Name="a"}, new Value{Data="1"}),
                                                       new Tuple<Parameter, Value>(new Parameter{Name="a"}, new Value{Data="99"})
                                                   });
        }
    }
}